Add filtering by code to vouchers in UI, fix e2e#6409
Add filtering by code to vouchers in UI, fix e2e#6409witoszekdev wants to merge 9 commits intomainfrom
Conversation
indexing, not available immediately)
🦋 Changeset detectedLatest commit: f99a45e The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6409 +/- ##
==========================================
- Coverage 43.19% 43.19% -0.01%
==========================================
Files 2527 2527
Lines 44074 44081 +7
Branches 10440 10405 -35
==========================================
+ Hits 19037 19040 +3
- Misses 23715 23718 +3
- Partials 1322 1323 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a “Code” filter to the Gift Cards conditional filter UI and updates the Playwright E2E test to use that filter instead of search (to avoid eventual indexing delays).
Changes:
- Add Gift Cards “Code” filter operand + condition configuration.
- Extend URL token parsing / initial-state plumbing to carry
codethrough the conditional filter system. - Update Gift Cards E2E to apply a “Code” text filter via the filters UI.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/ConditionalFilter/constants.ts | Adds the Gift Cards “Code” left operand and a new static condition entry. |
| src/components/ConditionalFilter/ValueProvider/UrlToken.ts | Marks code as a loadable static token for gift cards. |
| src/components/ConditionalFilter/ValueProvider/TokenArray/fetchingParams.ts | Adds code to gift-card fetching params + empty defaults. |
| src/components/ConditionalFilter/ValueProvider/TokenArray/fetchingParams.test.ts | Updates expectations to include code in params. |
| src/components/ConditionalFilter/API/providers/GiftCardsFilterAPIProvider.tsx | Adds a handler branch intended for the new code filter. |
| src/components/ConditionalFilter/API/initialState/helpers.ts | Threads code into initial gift-card state creation. |
| src/components/ConditionalFilter/API/initialState/giftCards/useInitialGiftCardsState.ts | Passes code into initial state and response. |
| src/components/ConditionalFilter/API/initialState/giftCards/InitialGiftCardsState.ts | Adds code storage/lookup for URL token rehydration. |
| playwright/tests/giftCards.spec.ts | Switches E2E from search to “Code” filter flow. |
| playwright/pages/pageElements/filtersPage.ts | Adds helper to pick a text filter in the filters UI. |
| playwright/pages/giftCardsPage.ts | Wires FiltersPage into the GiftCards page object. |
| isPreorder: [{ type: "select", label: "is", value: "input-1" }], | ||
| isGiftCardUsed: [{ type: "select", label: "is", value: "input-1" }], | ||
| isGiftCardBought: [{ type: "select", label: "is", value: "input-1" }], | ||
| giftCardCode: [{ type: "text", label: "is", value: "input-1" }], |
There was a problem hiding this comment.
STATIC_CONDITIONS key is giftCardCode, but the gift card left operand uses slug: "code"/value: "code". URL tokens and FilterElement.rowType() use value.value (the slug), so this mismatch prevents the condition from being rehydrated from URL and can make the filter behave as "unknown". Align the static condition key with the URL/slug (e.g. use code as the STATIC_CONDITIONS key) so ConditionOptions.isStaticName(token.name) works for this filter.
| giftCardCode: [{ type: "text", label: "is", value: "input-1" }], | |
| code: [{ type: "text", label: "is", value: "input-1" }], |
src/components/ConditionalFilter/API/providers/GiftCardsFilterAPIProvider.tsx
Outdated
Show resolved
Hide resolved
| case "usedBy": | ||
| return this.usedBy; | ||
| case "code": | ||
| return this.code; | ||
| default: |
There was a problem hiding this comment.
InitialGiftCardsStateResponse now supports resolving code tokens via getEntryByName, but the existing unit tests for filterByUrlToken() don’t cover this new case (they cover currency/tags/products/usedBy/isActive). Add a test for the code field to ensure URL rehydration works and to catch regressions when adjusting the code/giftCardCode naming.
| "saleor-dashboard": patch | ||
| --- | ||
|
|
||
| Gift cards filters now have option to filder by gift card code explicitly. Previously this was available only in search box, which uses `search` query, this however might not be available immediately after creating a gift card, due to indexing running in the background. |
There was a problem hiding this comment.
Typo in changeset text: "filder" should be "filter".
| Gift cards filters now have option to filder by gift card code explicitly. Previously this was available only in search box, which uses `search` query, this however might not be available immediately after creating a gift card, due to indexing running in the background. | |
| Gift cards filters now have option to filter by gift card code explicitly. Previously this was available only in search box, which uses `search` query, this however might not be available immediately after creating a gift card, due to indexing running in the background. |
| value: "code", | ||
| label: "Code", | ||
| type: "code", | ||
| slug: "code", | ||
| maxOccurrences: 1, | ||
| }, |
There was a problem hiding this comment.
New "Code" gift card filter is added, but there’s no unit test asserting how it maps into createGiftCardQueryVariables output (e.g. that a text "is" condition produces GiftCardFilterInput.code). Adding a focused test case in src/components/ConditionalFilter/queryVariables.test.ts would prevent regressions in this new filtering capability.
|
|
||
| readonly setGiftCardsBalanceDialog: SetGiftCardsBalanceDialog; | ||
|
|
||
| readonly filtersPage!: FiltersPage; |
There was a problem hiding this comment.
filtersPage is always initialized in the constructor, so the definite assignment assertion (!) is unnecessary and can mask real initialization issues. Declare it as readonly filtersPage: FiltersPage; instead.
| readonly filtersPage!: FiltersPage; | |
| readonly filtersPage: FiltersPage; |
Added option to filter gift cards by code in "Filter" menu, updated e2e test to use that filtering instead of search which takes a moment to index, which sometimes failed in test environment.